Socket
Socket
Sign inDemoInstall

ms-rest

Package Overview
Dependencies
Maintainers
2
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ms-rest

Client Runtime for Node.js client libraries generated using AutoRest


Version published
Maintainers
2
Created

What is ms-rest?

The ms-rest npm package is a runtime library for REST clients generated by AutoRest. It provides functionalities for making HTTP requests, handling responses, and managing authentication, among other things.

What are ms-rest's main functionalities?

HTTP Client

This feature allows you to send HTTP requests and handle responses. The code sample demonstrates how to create a ServiceClient instance and send a GET request to a specified URL.

const msRest = require('ms-rest');
const client = new msRest.ServiceClient();
client.sendRequest({
  method: 'GET',
  url: 'https://api.example.com/data'
}).then(response => {
  console.log(response.body);
}).catch(err => {
  console.error(err);
});

Authentication

This feature provides support for various authentication mechanisms. The code sample demonstrates how to authenticate using a service principal and then send an authenticated GET request.

const msRest = require('ms-rest');
const msRestAzure = require('ms-rest-azure');
msRestAzure.loginWithServicePrincipalSecret(clientId, secret, domain, (err, credentials) => {
  if (err) return console.error(err);
  const client = new msRest.ServiceClient(credentials);
  client.sendRequest({
    method: 'GET',
    url: 'https://api.example.com/data'
  }).then(response => {
    console.log(response.body);
  }).catch(err => {
    console.error(err);
  });
});

Custom Middleware

This feature allows you to add custom middleware to the request pipeline. The code sample demonstrates how to log requests and responses by adding a custom policy to the pipeline.

const msRest = require('ms-rest');
const client = new msRest.ServiceClient();
client.pipeline.addPolicy({
  sendRequest: (request, next) => {
    console.log('Request:', request);
    return next(request).then(response => {
      console.log('Response:', response);
      return response;
    });
  }
});
client.sendRequest({
  method: 'GET',
  url: 'https://api.example.com/data'
}).then(response => {
  console.log(response.body);
}).catch(err => {
  console.error(err);
});

Other packages similar to ms-rest

Keywords

FAQs

Package last updated on 02 May 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc